package com.demo.enumdemo;

/**
 * 通过构造方法为属性赋值
 * 
 * @author xiangty
 *
 */
enum ColorConstructorEnum {
	RED("红色"), GREEN("绿色"), BLUE("蓝色");
	private String name;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	private ColorConstructorEnum(String name) {
		this.setName(name);
	}

}

public class ConstructorEnumDemo {
	public static void main(String[] args) {
		for (ColorConstructorEnum c : ColorConstructorEnum.values()) {
			System.out.println(c.ordinal() + "---" + c.name() + "----" + c.getName());
		}
	}
}
